<template>
	<view class="u-flex u-row-center" v-if="noticeShow">
		<view class="notice_btn border_radius5 u-flex u-row-between u-color-white">
			<text :user-select="true">{{ noticeText }}</text>
			<view class="u-flex" v-if="[1,2,4].includes(noticeType)">
				<u-button @click="onSwitchNotice" class="u-p-r-20" size="mini"
					type="warning" v-if="[1].includes(noticeType)">订阅</u-button>
				<u-button @click="onSwitchNotice" class="u-p-r-20" size="mini"
					type="warning" v-if="[2].includes(noticeType)">开通</u-button>
				<u-button @click="onSwitchNotice" class="u-p-r-20" size="mini"
					type="warning" v-if="[4].includes(noticeType)">完善</u-button>
				<u-icon @click="onCloseNotice" size="26" color="#fff" name="close"></u-icon>
			</view>
			<view v-else @click="onRenew">马上续费 ></view>
		</view>
	</view>
</template>

<script>
	export default{
		props:{
			show:{
				type:Boolean,
				default:false
			},
			type:{
				type:Number,
				default: 4  // 1 订阅公众号  2 高级展厅开通引导  3 高级展厅有效期  4 引导完善个人信息
			},
			time:{
				type:String
			}
		},
		watch:{
			show:{
				deep: true,
				handler(newValue){
					this.noticeShow = newValue
				}
			},
			type:{
				deep: true,
				handler(newValue){
					this.noticeType = newValue
					this.onGetNoticeText()
				}
			},
			time:{
				deep: true,
				handler(newValue){
					this.noticeTime = newValue
					this.onGetNoticeText()
				}
			}
		},
		data(){
			return{
				noticeShow: this.show,
				noticeType: this.type,
				noticeTime: this.time,
				noticeText: '请完善个人详细信息，便于顺利组局'
			}
		},
		methods:{
			onSwitchNotice(){
				switch(this.noticeType){
					case 1:
					    uni.navigateTo({
					    	url: "/operate/webView/webView"
					    })
						break;
					case 2:
					    uni.navigateTo({
					    	url: "/operate/exhibition/exhibition"
					    })
					case 4:
					    this.$emit("goPerfect")
						break;
				}
			},
			onGetNoticeText(){
				switch(this.noticeType){
					case 1:
					    this.noticeText = '关注公众号，获取酒局最新消息'
						break;
					case 2:
					    this.noticeText = '开通高级名片，全面展示企业信息'
						break;
					case 3:
					    this.noticeText = `有效期至${this.noticeTime}`
						break;
					case 4:
					    this.noticeText = '请完善个人详细信息，便于顺利组局'
						break;
				}
			},
			onRenew(){
				this.$emit("onRenew")
			},
			onCloseNotice(){
				this.$emit("onCloseNotice")
			}
		}
	}
</script>

<style>
</style>